﻿@using Caltech.Extensions;
@using Role = Caltech.Service.Common.Roles;
@using Area = Caltech.Service.Common.Areas;

@{
    var hasAccess = new Func<Role, bool>((roleName) =>
    {
        var role = Enum.Parse(typeof(Role), ViewBag.RoleName);
        return role == Role.Admin || role == Role.Manager || roleName.HasFlag(role);
    });
}

<div class="navbar navbar-inverse navbar-fixed-top">
    <div class="container">
        <div class="navbar-header">
            <a ui-sref="home" class="navbar-brand">
                <img src="~/Content/images/logo2.jpg" style="height: 45px; margin-top: -12px;" />
            </a>
        </div>
        <div class="navbar-collapse collapse navbar-left">
            <ul class="nav navbar-nav">
                @if (Utils.HasAccess(Area.QuoteView))
                {
                    <li ui-sref-active="active"><a tabindex="-1" ui-sref="quote">Quote</a></li> }
                @if (Utils.HasAccess(Area.POView))
                {
                    <li ui-sref-active="active"><a tabindex="-1" ui-sref="po">PO</a></li> }
                @if (Utils.HasAccess(Area.WOView))
                {
                    <li ui-sref-active="active"><a tabindex="-1" ui-sref="workOrder">WO</a></li> }
                @if (Utils.HasAccess(Area.EquipmentView))
                {
                    <li ui-sref-active="active"><a tabindex="-1" ui-sref="equipment">Equipment</a></li> }
                @if (Utils.HasAccess(Area.CustomerView))
                {
                    <li ui-sref-active="active"><a tabindex="-1" ui-sref="customer">Customer</a></li> }

                @if (Utils.HasAccess(Area.CustomerEquipmentView))
                {
                    <li ui-sref-active="active"><a tabindex="-1" ui-sref="customerEquipment">Cust equipment</a></li> }
                @if (Utils.HasAccess(Area.CertificateView))
                {
                    <li ui-sref-active="active"><a tabindex="-1" ui-sref="certificate">Certificate</a></li> }
                @if (Utils.HasAccess(Area.StandardView))
                {
                    <li ui-sref-active="active"><a tabindex="-1" ui-sref="standard">Standard</a></li> }
                @if (Utils.HasAccess(Area.ProcedureView))
                {
                    <li ui-sref-active="active"><a tabindex="-1" ui-sref="procedure">Procedure</a></li>
                }
                @if (Utils.HasAccess(Area.AEView))
                {
                    <li ui-sref-active="active"><a tabindex="-1" ui-sref="ae">AE</a></li>
                }
                
                <li class="dropdown">
                    <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                        <span class="caret"></span>
                    </a>
                    <ul class="dropdown-menu" role="menu">
                        @if (Utils.HasAccess(Area.Report))
                        {
                            <li ui-sref-active="active"><a tabindex="-1" ui-sref="reports">Reports</a></li>
                        }
                        @if (Utils.HasAccess(Area.UserCreate))
                        {
                            <li ui-sref-active="active"><a tabindex="-1" ui-sref="userHistory">User History</a></li>
                        }
                        @if (Utils.HasAccess(Area.UserView))
                        {
                            <li ui-sref-active="active"><a tabindex="-1" ui-sref="user">User</a></li> }
                        @if (Utils.HasAccess(Area.Config))
                        {
                            <li ui-sref-active="active"><a tabindex="-1" ui-sref="config">Config</a></li> }                       
                    </ul>
                </li>

            </ul>
        </div>
        <ul class="nav navbar-nav navbar-right">
            <li class="dropdown">
                <a href="#" target="_self" class="dropdown-toggle" data-toggle="dropdown">
                    <i class="glyphicon glyphicon-user"></i> <span>@ViewBag.UserName</span> <b class="caret"></b>
                </a>
                <ul class="dropdown-menu">
                    <li class="dropdown-header">@ViewBag.RoleName</li>
                    <li><a tabindex="-1" id="logout-button" href="@Url.Action("Logout")"><i class="glyphicon glyphicon-log-out"></i> Log out</a></li>
                </ul>
            </li>
        </ul>
    </div>
</div>